home *** CD-ROM | disk | FTP | other *** search
/ MacAdvocate 2 / MACADVCT.ISO / mac / Goodies / Fun Stuff / Utilities / UltraFind / AppleScript™ Examples / UTF Find Untitled < prev    next >
Text File  |  1996-03-15  |  2KB  |  62 lines

  1. tell application "UltraFind 2.1"
  2.     clear
  3.     set the text of fileName of its searchRoutine to "untitled"
  4.     set the searchType of fileName of its searchRoutine to nameContains
  5.     set the fileKind of its searchRoutine to filesAndFolders
  6.     scan
  7. end tell
  8.  
  9. copy the result to numFiles
  10.  
  11. if numFiles is greater than 0 then
  12.     set dialogText to "Found " & (numFiles as text) & " untitled files : " & return & return
  13.     
  14.     set fileNum to 1
  15.     repeat until fileNum is greater than numFiles
  16.         
  17.         tell application "UltraFind 2.1"
  18.             copy (the name of fileRecord fileNum) to fName
  19.             copy (the fileKind of fileRecord fileNum) to fKind
  20.         end tell
  21.         
  22.         -- The Display Dialog routine cannot more than 255 characters so...
  23.         set addText to (fileNum as text) & ".  " & fKind & " ╥" & fName & "╙" & return
  24.         if (length of addText) + (length of dialogText) is less than 190 then
  25.             set dialogText to dialogText & addText
  26.         else
  27.             set dialogText to dialogText & return & "(..and more..)" & return
  28.             set fileNum to numFiles
  29.         end if
  30.         
  31.         set fileNum to fileNum + 1
  32.         
  33.     end repeat
  34.     
  35.     set dialogText to dialogText & return & "Do you want to trash these files?"
  36.     if the button returned of (display dialog dialogText buttons {"Yes", "No"} default button "No") is "Yes" then
  37.         
  38.         set myWasteBasket to ("Galileo:Trash" as alias)
  39.         repeat with fileNum from 1 to numFiles
  40.             tell application "UltraFind 2.1"
  41.                 copy (the accessPath of fileRecord fileNum) to fName
  42.             end tell
  43.             set aliasList to (fName as alias) as list
  44.             tell application "Finder"
  45.                 -- NOTE If using Finder 7.1.2 this may need modifying
  46.                 move to myWasteBasket from aliasList -- NOTE: un-comment for use with Finder 7.1.2 
  47.             end tell
  48.         end repeat
  49.         
  50.         set dialogText to (numFiles as text) & " items were trashed!" & return & return ┬
  51.             & "Do you want me to empty the wastebasket now?"
  52.         
  53.         if the button returned of (display dialog dialogText buttons {"Yes", "No"} default button "No") is "Yes" then
  54.             tell application "Finder"
  55.                 empty trash
  56.             end tell
  57.         end if
  58.         
  59.     end if
  60. end if
  61. tell application "UltraFind 2.1" to quit
  62.